<template>
  <div class="table">
    <el-table :data="tableData" border style="width: 100%">
      <template v-for="item in tableConfig" :key="item.prop">
        <el-table-column v-bind="item">
          <template #default="scope">
            <slot :name="item.slotName" :row="scope.row">
              {{ scope.row[item.prop] }}
            </slot>
          </template>
        </el-table-column>
      </template>
    </el-table>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref, PropType } from 'vue'
import { ITableConfig } from './types'

export default defineComponent({
  props: {
    modelValue: {
      type: Array,
      required: true
    },
    tableConfig: {
      type: Array as PropType<ITableConfig[]>,
      required: true
    }
  },
  setup(props, { emit }) {
    let tableData = ref([...props.modelValue])

    return { tableData }
  }
})
</script>
<style scoped lang="less">
.table {
}
</style>
